/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package py.sysbi.entidades;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author PROYECTO_2
 */
@Entity
@Table(name = "botiquin_detalle")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "BotiquinDetalle.findAll", query = "SELECT b FROM BotiquinDetalle b"),
    @NamedQuery(name = "BotiquinDetalle.findByBotiquin", query = "SELECT b FROM BotiquinDetalle b WHERE b.botiquinDetallePK.botiquin = :botiquin"),
    @NamedQuery(name = "BotiquinDetalle.findById", query = "SELECT b FROM BotiquinDetalle b WHERE b.botiquinDetallePK.id = :id"),
    @NamedQuery(name = "BotiquinDetalle.findByCantidad", query = "SELECT b FROM BotiquinDetalle b WHERE b.cantidad = :cantidad"),
    @NamedQuery(name = "BotiquinDetalle.findByDescripcion", query = "SELECT b FROM BotiquinDetalle b WHERE b.descripcion = :descripcion")})
public class BotiquinDetalle implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected BotiquinDetallePK botiquinDetallePK;
    @Column(name = "cantidad")
    private Integer cantidad;
    @Size(max = 255)
    @Column(name = "descripcion")
    private String descripcion;
    @JoinColumn(name = "medicamento", referencedColumnName = "id")
    @ManyToOne(fetch = FetchType.LAZY)
    private Medicamento medicamento;
    @JoinColumn(name = "botiquin", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Botiquin botiquin1;

    public BotiquinDetalle() {
    }

    public BotiquinDetalle(BotiquinDetallePK botiquinDetallePK) {
        this.botiquinDetallePK = botiquinDetallePK;
    }

    public BotiquinDetalle(int botiquin, int id) {
        this.botiquinDetallePK = new BotiquinDetallePK(botiquin, id);
    }

    public BotiquinDetallePK getBotiquinDetallePK() {
        return botiquinDetallePK;
    }

    public void setBotiquinDetallePK(BotiquinDetallePK botiquinDetallePK) {
        this.botiquinDetallePK = botiquinDetallePK;
    }

    public Integer getCantidad() {
        return cantidad;
    }

    public void setCantidad(Integer cantidad) {
        this.cantidad = cantidad;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Medicamento getMedicamento() {
        return medicamento;
    }

    public void setMedicamento(Medicamento medicamento) {
        this.medicamento = medicamento;
    }

    public Botiquin getBotiquin1() {
        return botiquin1;
    }

    public void setBotiquin1(Botiquin botiquin1) {
        this.botiquin1 = botiquin1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (botiquinDetallePK != null ? botiquinDetallePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BotiquinDetalle)) {
            return false;
        }
        BotiquinDetalle other = (BotiquinDetalle) object;
        if ((this.botiquinDetallePK == null && other.botiquinDetallePK != null) || (this.botiquinDetallePK != null && !this.botiquinDetallePK.equals(other.botiquinDetallePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.sysbi.entidades.BotiquinDetalle[ botiquinDetallePK=" + botiquinDetallePK + " ]";
    }
    
}
